package com.suyang.syt.util;

import java.security.MessageDigest;

public class Sha1Util {

	private Sha1Util() {

	}

	/** 对str进行sha1加密,返回加密完成的字符串 */
	public static String sha1(String str) throws Exception {
		StringBuilder sb = new StringBuilder();
		MessageDigest messageDigest = MessageDigest.getInstance("sha1");
		messageDigest.update(str.getBytes());
		byte[] bytes = messageDigest.digest();
		for (byte b : bytes) {
			sb.append(String.format("%02x", b));
		}
		return sb.toString();
	}

}
